<%inherit file="base.html"/>

<%def name="head()">
<script>
    function deleteTpl(tpl_id) {
        if (confirm("确认删除吗？")) {
            window.location.href = "/admin/contenttpl/delete?tpl_id=" + tpl_id;
        }
    }
</script>

</%def>

<%def name="body()">
<section class="content">
    <div class="box box-primary">
        <div class="box-header">
            <i class="fa fa-map-marker"></i>
            <h3 class="box-title">内容模板管理</h3>
        </div>
    <div class="box-body">
     <div class="container">
        <div class="pull-right bottom10">
            % if permit.match(current_user.username,'/admin/contenttpl/add'):
             <a href="/admin/contenttpl/add" class="btn btn-sm btn-default">
                  增加模板</a>
            % endif
        </div>
        <table class="table table-hover">
            <thead>
            <tr>
                <th>模板类型</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            % for tpl in tpls:
            <tr>
                <td>${tpl_types[tpl.tpl_type]} - ${tpl.tpl_type}</td>
                <td>
                    % if permit.match(current_user.username,'/admin/contenttpl/update'):
                    <a class="opt-btn btn-default" href="/admin/contenttpl/update?tpl_id=${tpl.id}">修改</a>
                    % endif
                    % if permit.match(current_user.username,'/admin/contenttpl/delete'):
                    <a class="opt-btn btn-default" href="javascript:deleteTpl('${tpl.id}')">删除</a>
                    % endif
                </td>
            </tr>
            % endfor
            </tbody>
        </table>
    </div>
</div>
</div>
</section>

</%def>